home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 04 - 1988 / 04.02 Feb 88 / pascal sources / Plot Project Stuff / myPrintStuff < prev    next >
Encoding:
Text File  |  1988-01-09  |  2.8 KB  |  119 lines  |  [TEXT/PJMM]

  1.  
  2. UNIT MyPrintStuff;
  3.  
  4. INTERFACE
  5.  
  6.     USES
  7.         ROM85, PrintTraps, PlotGlobals, Misc, myFileStuff, Solve;
  8.  
  9.     PROCEDURE doPageSet;
  10.     PROCEDURE doPrint;
  11.  
  12. IMPLEMENTATION
  13.  
  14.     PROCEDURE PrintMe;
  15.         CONST
  16.             LaserWriter = 2;
  17.         VAR
  18.             theWorld : rect;
  19.             pstate : penstate;
  20.     BEGIN
  21.         theWorld := PicRect;
  22.         IF Option = 1 THEN
  23.             theWorld := PicRect
  24.         ELSE IF Option = 2 THEN
  25.             theWorld := PageRect
  26.         ELSE
  27.             doMessage('Printing Rectangle Problem', '', '', '');
  28.         GetPenState(pstate);
  29.         PrintingPic := OpenPicture(theWorld);
  30.         PrQDStuff(theWorld, LaserWriter);
  31.         ClosePicture;
  32.         SetPenState(pstate);
  33.         DrawPicture(PrintingPic, theWorld);
  34.         KillPicture(PrintingPic);
  35.     END;
  36.  
  37.     PROCEDURE doPrint;
  38.         VAR
  39.             DoIt : boolean;
  40.             myPrint : THPrint;
  41.             myPrStatus : TPrStatus;
  42.             myPrPort : TPPrPort;
  43.             PrRect : rect;
  44.             str1 : str255;
  45.             temp : GrafPtr;
  46.             numCopies : integer;
  47.             count : integer;
  48.             prStatus : TPrStatus;
  49.     BEGIN {1}
  50.         IF DrawingPic <> NIL THEN
  51.             BEGIN {2}
  52.                 myPrint := PlotDocHandle^^.print;
  53.                 getport(temp);
  54.                 PrOpen;
  55.                 IF PrError = noErr THEN
  56.                     BEGIN {3}
  57.                         DoIt := PrValidate(myPrint);
  58.                         DoIt := PrJobDialog(myPrint);
  59.                         IF PrError <> noErr THEN
  60.                             doMessage('Printer error in job dialog', '', '', '');
  61.                         IF DoIt THEN
  62.                             BEGIN {4}
  63.                                 myPrPort := PrOpenDoc(myPrint, NIL, NIL);
  64.                                 IF PrError = noErr THEN
  65.                                     BEGIN {5}
  66.                                         numCopies := myPrint^^.prJob.iCopies;
  67.                                         FOR count := 1 TO numCopies DO
  68.                                             BEGIN {6}
  69.                                                 PrOpenPage(myPrPort, NIL);
  70.                                                 IF PrError = noErr THEN
  71.                                                     BEGIN {7}
  72.                         { print something dummy!}
  73.                                                         PageRect := myPrint^^.prInfo.rPage;
  74.                                                         PrintMe;
  75.                                                     END { 7}
  76.                                                 ELSE
  77.                                                     doMessage('OpenPage error', 'cannot print this page', '', '');
  78.                                                 PrClosePage(myPrPort);
  79.                                                 IF PrError <> noErr THEN
  80.                                                     doMessage('ClosePage error', 'cannot close this page', '', '');
  81.                                             END; {6}
  82.                                     END { 5}
  83.                                 ELSE
  84.                                     doMessage('OpenDoc error', 'cannot print', '', '');
  85.                                 PrCloseDoc(myPrPort);
  86.                                 IF PrError <> noErr THEN
  87.                                     doMessage('CloseDoc error', '', '', '');
  88.                                 IF (myPrint^^.prJob.bJDocLoop = bSpoolLoop) AND (PrError = noerr) THEN
  89.                                     PrPicFile(myPrint, NIL, NIL, NIL, prStatus);
  90.                             END; {4}
  91.                     END; {3}
  92.                 PrClose;
  93.                 setport(temp);
  94.             END;{2}
  95.     END; {of proc 1}
  96.  
  97.  
  98.     PROCEDURE doPageSet;
  99.         VAR
  100.             DoIt : boolean;
  101.             myPrint : THPrint;
  102.     BEGIN
  103.         myPrint := PlotDocHandle^^.print;
  104.         PrOpen;
  105.         IF PrError = noErr THEN
  106.             BEGIN
  107.                 DoIt := PrValidate(myPrint);
  108.                 DoIt := PrStlDialog(myPrint);
  109.                 IF PrError <> noErr THEN
  110.                     doMessage('Printer error in style dialog', '', '', '')
  111.                 ELSE
  112.                     PageRect := myPrint^^.prInfo.rpage;
  113.             END
  114.         ELSE
  115.             doMessage('Cannot perform PrOpen!', '', '', '');
  116.         PrClose;
  117.     END;
  118.  
  119. END. {of unit}